package arithmetic.socket.netty.serverClient;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author jiangfeng
 * Created on 2020-03-01
 */
public class NettyClient {

    public static void main(String[] args) throws InterruptedException {
        NioEventLoopGroup work = new NioEventLoopGroup();
        try {
            Bootstrap bootstrap = new Bootstrap();
            bootstrap.group(work).channel(NioSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.WARN))
                    .handler(new ClientNettyInitailizer());
            ChannelFuture channelFuture = bootstrap.connect("localhost", 10001).sync();
            channelFuture.channel().closeFuture().sync();

        }finally {
            work.shutdownGracefully();
        }

    }
}
